<?php
require_once './db.php';

if(isset($_POST['last'])){
	$last = (int)$_POST['last'];
}else{
	$last = 0;
}

$res = mysql_query("select title, link, timestamp, col, image, content from blog order by timestamp desc limit {$last},10");
$arr = Array();
while($row = mysql_fetch_assoc($res)){
	if(!empty($row['image'])){
		$row['image'] = base64_encode($row['image']);
	}
	$arr[] = $row;
}

header('Content-Type: application/json');
echo json_encode($arr);
